package com.jy.datapipeline.export.service.impl;

import com.jy.datapipeline.export.dao.DataStoreInfoDao;
import com.jy.datapipeline.export.dao.repo.DataStoreInfoDaoRepo;
import com.jy.datapipeline.export.entity.DataStoreInfoModel;
import com.jy.datapipeline.export.service.DataStoreInfoService;
import java.util.List;
import java.util.Map;
import java.util.Optional;
import org.springframework.transaction.annotation.Transactional;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Slf4j
@Service
@Transactional
public class DataStoreInfoServiceImpl implements DataStoreInfoService {
    @Autowired
    private DataStoreInfoDao dataStoreInfoDao;
    @Autowired
    private DataStoreInfoDaoRepo dataStoreInfoDaoRepo;
    @Override
    public boolean saveDataStoreInfo(DataStoreInfoModel dsim) {
        this.dataStoreInfoDaoRepo.save(dsim);
        return true;
    }

    @Override
    public boolean updateDataStoreInfo(DataStoreInfoModel dsim) {
        return this.dataStoreInfoDao.updateDataStoreInfo(dsim);
    }

    @Override
    public boolean deleteDataStoreInfoById(int id) {
        this.dataStoreInfoDaoRepo.deleteById(id);
        return true;
    }

    @Override
    public List<Map<String, Object>> findDataStoreInfoByList(String storeName, String storeType,
        int iDisplayStart, int iDisplayLength) {
        return this.dataStoreInfoDao.findDataStoreInfoByList(storeName,storeType,iDisplayStart,iDisplayLength);
    }

    @Override
    public int findDataStoreInfoByCount(String storeName, String storeType) {
        return this.dataStoreInfoDao.findDataStoreInfoByCount(storeName,storeType);
    }

    @Override
    public DataStoreInfoModel findByStoreName(String storeName) {
        return this.dataStoreInfoDaoRepo.findByStoreName(storeName);
    }

    @Override
    public DataStoreInfoModel findByStoreId(String storeId) {
        return this.dataStoreInfoDaoRepo.findByStoreId(storeId);
    }

    @Override
    public DataStoreInfoModel findById(int id) {
        Optional<DataStoreInfoModel> op=  this.dataStoreInfoDaoRepo.findById(id);
        return op.get();
    }
}
